home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Graphics Samples / Text To Outlines ƒ / Text To Outlines.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-15  |  3.8 KB  |  135 lines  |  [TEXT/KAHL]

  1. /**
  2.     Text To Outlines.c
  3.     
  4.     This application will create a gxLine of text, and convert it to a gxPath gxShape. By changing the
  5.     sample to a gxPath will give you the outlines of each character. 
  6.     
  7.     
  8.     NOTES:
  9.     • This file requires the following files to run correctly:
  10.         "graphics shell.c", "FontLibrary.c", "GraphicsDebugLibrary.c", "TransformLibrary.c".
  11.  
  12.     • This file prints the "best" in landscape mode.
  13.     
  14.     Change History:
  15.  
  16.        4/96    bob        Updated #includes to support changed GX Library names.
  17.                     Updated the note regarding the files needed to run.
  18.                     Updated the copyright date.
  19.  
  20.     ©1990-1996  Apple Computer, Inc.
  21.     All rights reserved.
  22. **/
  23.  
  24. #include <Events.h>
  25. #include <Windows.h>
  26.  
  27. #include "GraphicsLibraries.h"
  28. #include <GXEnvironment.h>
  29. #include "FontLibrary.h"
  30. #include "graphics shell.h"
  31.  
  32.  
  33. //
  34. //  Set up the title and size of the window 
  35. //
  36. Str255         gWindowTitle = "\p Text To Outlines ";         
  37. Rect         gWindowQDRect  = {50, 10, 280, 460};
  38.  
  39. //
  40. //    gGraphicsHeapSize sets the size of the graphics gxHeap created by calling the GXNewGraphicsClient routine
  41. //    in main () within graphics shell.c.  You can determine the amount of graphics gxHeap required by using GraphicsBug.
  42. //    With  gGraphicsHeapSize set to 15k, I had 4 free blocks left in the graphics gxHeap. Sounds good to me.
  43. //
  44. long        gGraphicsHeapSize = 75;
  45.  
  46. gxShape         gTextOutlineShape;
  47.  
  48.  
  49.  
  50. /*------ DoInitialization ---------------------------------------------------------------------------------*/
  51.  
  52. void DoInitialization(aWindow)
  53. WindowPtr aWindow;
  54. {
  55.     gxPoint    textPostion;
  56.     gxColor     textOutlineColor;
  57.     
  58.     //
  59.     //    Set up the starting text postion. This location will be set up when we
  60.     //    create our text gxShape.
  61.     //
  62.     textPostion.x = ff(30);
  63.     textPostion.y = ff(150);
  64.     
  65.     //
  66.     //  Create the text, and set the gxFont and size.
  67.     //
  68.     gTextOutlineShape = GXNewText(5,(unsigned char*)"Waves", &textPostion);
  69.     SetShapeCommonFont(gTextOutlineShape, timesFont);
  70.     GXSetShapeTextSize(gTextOutlineShape, ff(145));
  71.  
  72.     GXSetShapeType(gTextOutlineShape, gxPathType);
  73.     GXSetShapeFill(gTextOutlineShape, gxClosedFrameFill);
  74.     GXSetShapePen(gTextOutlineShape, ff(2));
  75.     GXSetShapeStyleAttributes(gTextOutlineShape, gxOutsideFrameStyle);
  76.  
  77.     
  78.     //
  79.     //    A gxColor, to run through hsv space with... 
  80.     //
  81.     textOutlineColor.space                     = gxHSVSpace;
  82.     textOutlineColor.profile                 = nil;
  83.     textOutlineColor.element.hsv.hue         = 0xD4DA;
  84.     textOutlineColor.element.hsv.saturation = 0xD657;
  85.     textOutlineColor.element.hsv.value         = 0xFFFF;
  86.  
  87.     GXSetShapeColor(gTextOutlineShape, &textOutlineColor);
  88. }
  89.  
  90.  
  91.  
  92. /*------ DoDraw ---------------------------------------------------------------------------------------*/
  93.  
  94. void DoDraw(aWindow)
  95. WindowPtr aWindow;
  96. {
  97.     GXDrawShape (gTextOutlineShape);
  98. }
  99.  
  100.  
  101. /*------ DoDispose -------------------------------------------------------------------------------------*/
  102.  
  103. void DoDispose(aWindow)
  104. WindowPtr aWindow;
  105. {
  106.     //  
  107.     //    You should always dispose of your GX graphics objects before tossing your window. Why? It's generally good 
  108.     //    form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
  109.     //    call to DisposeWindow should dispose of the objects. If you are running the debugging version of the 
  110.     //    SecretGraphics init with notices set, you will receive a notice that you had not disposed of everything. You
  111.     //    can turn notices on in this file by setting gDebugging = TRUE (above).
  112.     //
  113.     GXDisposeShape(gTextOutlineShape);  
  114.     GXDisposeShape(gWindowBoundsShape);  
  115.        DisposeWindow(aWindow);
  116. }
  117.     
  118.  
  119.  
  120. /*------ DoClick ---------------------------------------------------------------------------------------*/
  121.  
  122. void DoClick( orgMouseLoc, theWindow )
  123. gxPoint        orgMouseLoc;
  124. WindowPtr     theWindow;
  125. {
  126. }
  127.  
  128.  
  129. /*------ DoIdle ----------------------------------------------------------------------------------------*/
  130.  
  131. void DoIdle(aWindow)
  132. WindowPtr aWindow;
  133. {
  134. }
  135.